package com.zhiyou100.crm.servlet.customerSource;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//import com.zhiyou100.crm.model.CustomerSource;/
import com.zhiyou100.crm.service.CustomerSourceService;
import com.zhiyou100.crm.service.impl.CustomerSourceServiceImpl;
import com.zhiyou100.crm.util.AdminBaseServlet;
import com.zhiyou100.crm.util.CustomerSource;

@WebServlet(urlPatterns = { "/customerSource/list" })
public class ListServlet extends AdminBaseServlet {
	private static final long serialVersionUID = 1L;

	CustomerSourceService customerSourceService = new CustomerSourceServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=UTF-8");
		List<CustomerSource> list = customerSourceService.qureyAll();
		if(list!=null) {
			request.setAttribute("list", list);
			request.getRequestDispatcher("/WEB-INF/view/customerSource/list.jsp").forward(request, response);
		}else {
			request.getRequestDispatcher("/WEB-INF/view/customerSource/list.jsp").forward(request, response);
		}
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		super.doPost(req, resp);
	}
}
